{% extends 'posts.html' %}
{% import '_pagination.html' as pagination %}
{% block content %}
  <div class="layui-col-md8">
    {% if is_index %}
      <div class="fly-panel">
        <div class="fly-panel-title fly-filter">
          <a>置顶</a>
          <a href="#signin" class="layui-hide-sm layui-show-xs-block fly-right" id="LAY_goSignin"
             style="color: #FF5722;">去签到</a>
        </div>
        <ul class="fly-list">
          {% set top_list=get_list('posts', sort_by=('_id', -1), filter1={'is_top':True}) %}
          {% for item in top_list %}
            {% include '_list_item.html' %}
          {% else %}
            <div style="min-height: 60px; text-align: center; padding-top:50px; color: #999;">没有相关数据</div>
          {% endfor %}
        </ul>
      </div>
    {% endif %}


    <div class="fly-panel" style="margin-bottom: 0;">
      {% set url_prefix=("/catalog/" + catalog_id|string) if catalog_id else '/' %}
      {% set url_suffix=(('?sort_key=' + sort_key) if sort_key else '') + ('&type=' + post_type if post_type else '') %}

      <div class="fly-panel-title fly-filter">
        <a href="{{ url_prefix }}?sort_key={{ sort_key }}" {{ 'class=layui-this' if not post_type }}>综合</a>
        <span class="fly-mid"></span>
        <a href="{{ url_prefix }}?sort_key={{ sort_key }}&type=not_closed" {{ 'class=layui-this' if post_type == 'not_closed' }}>未结</a>
        <span class="fly-mid"></span>
        <a href="{{ url_prefix }}?sort_key={{ sort_key }}&type=is_closed" {{ 'class=layui-this' if post_type == 'is_closed' }}>已结</a>
        <span class="fly-mid"></span>
        <a href="{{ url_prefix }}?sort_key={{ sort_key }}&type=is_cream" {{ 'class=layui-this' if post_type == 'is_cream' }}>精华</a>
        <span class="fly-filter-right layui-hide-xs">
            <a href="{{ url_prefix }}?sort_key=_id{{ '&type=' + post_type if post_type }}" {{ 'class=layui-this' if sort_key == '_id' }}>按最新</a>
            <span class="fly-mid"></span>
            <a href="{{ url_prefix }}?sort_key=comment_count{{ '&type=' + post_type if post_type }}" {{ 'class=layui-this' if sort_key == 'comment_count' }}>按热议</a>
          </span>
      </div>

      <ul class="fly-list">
        {% for item in page.result %}
          {% include '_list_item.html' %}
        {% else %}
          <div style="min-height: 60px; text-align: center; padding-top:50px; color: #999;">没有相关数据</div>
        {% endfor %}
      </ul>
      {% if page.total_page > 1 %}
{#        {% include '_pagination.html' %}#}
        {{ pagination.paginate(page, url_prefix, url_suffix) }}
      {% endif %}
    </div>
  </div>
{% endblock %}